/** 
 * 信息
 */

import {showNumberIn6} from "/stock/kelly4s.js"

export async function main(ns) {
  let data = ns.getMoneySources();
  ns.tprint("####    getMoneySources:    ####");
  for(let i in data)
  {
    if("object" ==typeof (data[i]))
    {
      ns.tprint("\t",i,":");
      for(let i2 in data[i])
      {
        ns.tprint("\t\t",i2,":\t",data[i][i2]);
      }
    }
    else
    {
      ns.tprint("\t",i,":\t",data[i]);
    }
  }

  var last_hacking =0;
  var last_gang = 0;
  var last_stock = 0;
  var last_hacknet = 0;
  var last_crime = 0;
  // BEGIN 计算
  do
  {
    data = ns.getMoneySources();
    let data2 = data['sinceInstall'];
    let crime = data2['crime'];
    let delta_crime = crime-last_crime;
    ns.print("犯罪所得:\t",showNumberIn6(crime)," \t 每小时:",showNumberIn6(delta_crime));
    last_crime = crime;
    let hacknet = data2['hacknet'];
    let delta_hacknet = hacknet-last_hacknet;
    ns.print("hacknet所得:\t",showNumberIn6(hacknet)," \t 每小时:",showNumberIn6(delta_hacknet));
    last_hacknet = hacknet;
    let hacking = data2['hacking'];
    let delta_hack = hacking - last_hacking;
    ns.print("hack所得:\t",showNumberIn6(hacking)," \t 每小时:",showNumberIn6(delta_hack));
    last_hacking = hacking;
    let stock = data2['stock'];
    let delta_stock = stock-last_stock;
    ns.print("股票所得:\t",showNumberIn6(stock)," \t 每小时:",showNumberIn6(delta_stock));
    last_stock = stock;
    // let delta_hack_seconds = delta_hack/3600;
    // ns.print("hack速度:", showNumberIn6(delta_hack_seconds),"/s);
    let gang = data2.gang;
    let delta_gang = gang-last_gang;
    ns.print("帮派所得:\t",showNumberIn6(gang),"\t每小时:",showNumberIn6(delta_gang));
    last_gang = gang;
    // 总计:
    ns.print("总的赚钱速度(每小时):",showNumberIn6(
      delta_crime    +
      delta_hacknet  +  
      delta_hack     +
      delta_stock    +
      delta_gang
    ));

    await ns.sleep(3600000);
  }while(true);
  // END 计算
}